// pages/profile-detail/index.js
Page({
  data: {
    userInfo: {
      avatar: "/assets/img/profile/profile.png",
      nickname: "城旅达人",
      level: 15,
      experience: 75,
      points: 1280,
      joinTime: "2023-06-15",
      lastActive: "2024-01-15 14:30"
    },
    stats: {
      posts: 128,
      followers: 256,
      following: 45,
      likes: 1234
    },
    recentPosts: [
      {
        id: 1,
        content: "今天发现了一家超棒的咖啡店！",
        image: "/assets/img/message/精品推荐2.jpg",
        time: "2024-01-15 10:30",
        likes: 23,
        comments: 5
      },
      {
        id: 2,
        content: "周末徒步路线分享，风景绝美！",
        image: "/assets/img/message/精品推荐4.jpg",
        time: "2024-01-14 18:30",
        likes: 45,
        comments: 8
      },
      {
        id: 3,
        content: "推荐几个隐藏的美食小店",
        image: "/assets/img/message/精品推荐6.jpg",
        time: "2024-01-13 20:10",
        likes: 67,
        comments: 12
      }
    ],
    achievements: [
      { name: "新手上路", icon: "🏃", status: "completed" },
      { name: "活跃用户", icon: "💬", status: "completed" },
      { name: "美食达人", icon: "🍽️", status: "completed" },
      { name: "摄影大师", icon: "📸", status: "in_progress" },
      { name: "社区明星", icon: "⭐", status: "locked" }
    ]
  },

  onLoad: function (options) {
    wx.setNavigationBarTitle({
      title: '个人资料'
    })
  },

  onEditTap: function() {
    wx.showModal({
      title: '编辑资料',
      content: '确定要编辑个人资料吗？',
      success: function(res) {
        if (res.confirm) {
          wx.showToast({
            title: '编辑功能开发中',
            icon: 'none'
          })
        }
      }
    })
  },

  onFollowTap: function() {
    wx.showToast({
      title: '关注功能开发中',
      icon: 'none'
    })
  },

  onMessageTap: function() {
    wx.showToast({
      title: '私信功能开发中',
      icon: 'none'
    })
  },

  onPostTap: function(e) {
    const post = e.currentTarget.dataset.post
    
    wx.showModal({
      title: '动态详情',
      content: `${post.content}\n\n发布时间：${post.time}\n点赞：${post.likes} 评论：${post.comments}`,
      showCancel: true,
      cancelText: '关闭',
      confirmText: '查看详情',
      success: function(res) {
        if (res.confirm) {
          wx.showToast({
            title: '详情页面开发中',
            icon: 'none'
          })
        }
      }
    })
  },

  onAchievementTap: function(e) {
    const achievement = e.currentTarget.dataset.achievement
    
    let content = `成就：${achievement.name}\n状态：`
    if (achievement.status === "completed") {
      content += "已完成 ✅"
    } else if (achievement.status === "in_progress") {
      content += "进行中 🔄"
    } else {
      content += "未解锁 🔒"
    }
    
    wx.showModal({
      title: '成就详情',
      content: content,
      showCancel: true,
      cancelText: '关闭',
      confirmText: '确定'
    })
  }
})
